<?php
/**
 *
 * ============================================================================
 * * 版权所有 度拉拉 * *
 * 网站地址: http://www.dlltrip.com
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * Author By: 倪宗锋
 * PhpStorm OrderController.php
 * Create By 2017/7/3 18:49 $
 */

namespace zzcx\controllers\user;


use common\Controller\ZzcxController;
use common\service\login\LoginService;
use common\util\Util;
use zzcx\service\user\Order;

class OrderController extends ZzcxController
{
    private $service = null;

    public function service()
    {
        if ($this->service == null) {
            $this->service = new Order();
        }
        return $this->service;
    }

    /**
     * Des:获取用户的订单列表
     * Name: actionGetList
     * @return string
     * @author 倪宗锋
     */
    public function actionGetList()
    {
        $params = [
            'order_status' => $this->_post('order_status', ''),
            'current_page' => $this->_post('current_page', 1),
            'page_size' => $this->_post('page_size', 10),
            'sh_uid' => LoginService::$uid
        ];
        if ($params['order_status'] == '5') {
            $params['order_status'] = '4,5,6';
        }
        $getList = $this->service()->getList($params);
        return Util::returnJsSu('', $getList['data']);
    }

    /**
     * Des:获取订单详情
     * Name: actionGetOrderInfo
     * @return string
     * @author 倪宗锋
     */
    public function actionGetOrderInfo()
    {
        $order_id = $this->_post('order_id', '');
        $orderIdList =  explode('-', $order_id);
        $getInfo = $this->service()->getOrderInfo($orderIdList[0]);
        if ($getInfo['flag'] == false) {
            return Util::returnJsEr($getInfo['msg']);
        }
        return Util::returnJsSu('', $getInfo['data']);
    }

    /**
     * Des:取消订单
     * Name: actionCancel
     * @return string
     * @author 倪宗锋
     */
    public function actionCancel()
    {
        $order_id = $this->_post('order_id', '');
        $getInfo = $this->service()->cancel($order_id);
        if ($getInfo['flag'] == false) {
            return Util::returnJsEr($getInfo['msg']);
        }
        return Util::returnJsSu();
    }

}